# -*- coding: utf-8 -*-
"""
@Time ： 2023/4/17 21:21
@Auth ： 叶东宇
@File ：fourSumoneList.py
"""

def fourSumOneList(nums, target):
    nums = sorted(nums, key=lambda x:x)
    dic = dict()
    for i in range(len(nums)):
        for j in range(i+1, len(nums)):
            if nums[i] + nums[j] not in dic:
                dic[nums[i]+nums[j]] = [[i, j]]
            else:
                if [i, j] not in dic[nums[i]+nums[j]]:
                    dic[nums[i] + nums[j]].append([i, j])
    lis = []
    for i in dic.keys():
        if target - i in dic:
            for j in dic[i]:
                for k in dic[target - i]:
                    if j == k:
                        continue
                    if len(set(k + j)) == 4:
                        tmp_j = [nums[m] for m in j]
                        tmp_k = [nums[n] for n in k]
                        tmp = sorted((tmp_j + tmp_k), key=lambda x:x)
                        if tmp not in lis:
                            lis.append(tmp)
    return lis

if __name__ == "__main__":
    nums = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90]
    target = 200
    print(fourSumOneList(nums, target))
